<?php

global $connect;

if (isset($_GET['cmd_id']) AND $_GET['cmd_id'] != NULL)
{

	$sql = "SELECT `LIVRER` AS `livrer` FROM `commandes` WHERE `NCOMMANDE` = '".$_GET['cmd_id']."'";
	$result = mysql_query($sql) or die(mysql_error());
	$data = mysql_fetch_array($result);
	$liv = $data['livrer'];

	if ($liv == 0)
		echo "<div class='box_info'>Cette commande n'a pas encore &eacute;t&eacute; totalement livr&eacute;</div>";
	else if ($liv == 1)
		echo "<div class='box_info'>Cette commande a &eacute;t&eacute; livrer</div>";
	echo "<br/>";
	
	$sql = "SELECT c.NPRODUIT AS `id_produit`, c.QUANTITECMD AS `qtcmd`, c.QUANTITERECU AS `qtrecu`, p.MARQUE AS `marque` FROM `contenir` c LEFT JOIN `produits` p ON (p.NPRODUIT = c.NPRODUIT) WHERE c.NCOMMANDE = '".$_GET['cmd_id']."'";
	//echo $sql;
	$result = mysql_query($sql) or die(mysql_error());
	echo "<form  method='post' action='index.php?page=magasins'><center><table><thead><tr><th>Produits</th><th>Qt cmd</th><th>Qt recu</th></tr></thead>";
	while ($data = mysql_fetch_array($result))
	{
		echo "<tr>";
		echo "<td>".$data['marque']."</td>";
		echo "<td>".$data['qtcmd']."</td>";
		if ($liv == 0)
			echo "<td><input value='".$data['qtrecu']."' name='".$data['id_produit']."'/></td>";
		echo "</tr>";
	}
	if ($liv == 0)
		echo "</table><input type='submit' value='Valider'/></center></form>";
	else
		echo "</table></center></form>";
		
	echo "<br /><center><h3><a href='index.php?page=magasins&action=livraison&id_mag=".$_GET['id_mag']."'>Retour</a></h3></center>";
}

?>